<template>
  <div class="content-bottom">
    <div class="resourcecontrol">
      <div
        v-for="(item, index) in pumpMapList"
        :key="index"
        :class="{ resource: true, active: currentItem === item.id }"
        @click="handleResourceClick(item)"
      >
        <span class="name">{{ item.value }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import { pumpMapList } from './titles';
export default {
  props: {
    currentItem: String
  },
  data() {
    return {
      pumpMapList: [],
      centerInfo: []
    };
  },
  watch: {},
  mounted() {
    this.pumpMapList = pumpMapList;
    this.handleResourceClick({ id: this.currentItem });
  },
  methods: {
    handleResourceClick(val) {
      const { id } = val;
      if (['ZY', '401_01', '401_02', '402'].includes(id)) {
        const sceneName = this.pumpMapList.find(item => id === item.id).sceneName;
        this.$router.push({ name: 'waterDetails', params: { id }});
        this.$store.dispatch('postToEngine', { sceneName });
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.resourcecontrol {
  position: fixed;
  left: 50%;
  bottom: 2.5rem;
  z-index: 10;
  transform: translateX(-50%);
  // width: 65.375rem;
  width: 33.375rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9375rem 1.875rem;
  height: 3.125rem;
  background-color: rgba($color: $black, $alpha: 0.4);
  .return-box {
    width: 5.1875rem;
    height: 1.875rem;
    line-height: 1.875rem;
    border-right: 0.0625rem solid rgba(0, 0, 0, 0.2);
    font-weight: bold;
    color: $cyan;
    cursor: pointer;
    img {
      margin-right: 0.3125rem;
      width: 1.25rem;
      height: 1.25rem;
      vertical-align: text-bottom;
    }
  }
  .resource {
    color: $light2Grey;
    cursor: pointer;
    .icon {
      position: relative;
      top: 0.25rem;
      margin-right: 0.625rem;
      width: 1.25rem;
      height: 1.25rem;
    }
    &.active {
      .name {
        color: $cyan;
      }
    }
  }
}
</style>
